#!/usr/bin/env python

import unittest,sys,os,getopt
from SpectralMix import DistanceMatrix

### parse inputs 
VERBOSE = False
optlist, args = getopt.getopt(sys.argv[1:], 'v')
for o, a in optlist:
    if o == '-v':
        VERBOSE = True

## test the DistanceMatrix class
class DistanceMatrixTest(unittest.TestCase):
    
    def testAllTests(self):
        self.species = 'yeast'
        self.csvFileName  = os.path.join(".","tests","data","DistMatrixExampleYeast.csv")
        self.dMat = DistanceMatrix(self.species,csvFile=self.csvFileName)
        self.failUnless(len(self.dMat.pairwiseDict.keys()[2:10]) == 8)
        dist = self.dMat.get_dist('PRP8','HXT1')
        self.failUnless(dist > 0)

        ## testing for presense of the summary statistics
        self.failUnless(self.dMat.stats['mean'] > 0)
        self.failUnless(self.dMat.stats['max'] > 0)

        ## testing to see if graph is made correctly
        testGenes = ['TKL2','PGI1','SOL2','PRS2','PFK1','SOL4','GND2','PRS3','SOL3','GND1','RPE1','FBA1','PGM1']
        G = self.dMat.get_nx_graph(testGenes)
        testGenes = testGenes

        for element in testGenes:
            self.assert_(element in G.nodes())      
        
### Run the tests 
if __name__ == '__main__':
    unittest.main()
